//package com.jiawa.wiki.interceptor;
//
//import com.jiawa.wiki.config.WikiApplication;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.stereotype.Component;
//import org.springframework.web.servlet.HandlerInterceptor;
//import org.springframework.web.servlet.ModelAndView;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
//@Component
//public class LogInterceptor implements HandlerInterceptor {
//    private static final Logger LOG = LoggerFactory.getLogger(WikiApplication.class);
//    @Override
//    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//        LOG.info("===== Log Interceptor开始 =====");
//        long startTime = System.currentTimeMillis();
//        request.setAttribute("requestStartTime", startTime);
//        LOG.info("请求地址: {} {} ",request.getRequestURL().toString(),request.getMethod());
//        LOG.info("远程地址: {}",request.getRemoteAddr());
//        return true;
//    }
//
//    @Override
//    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
//        long startTime =   (Long)request.getAttribute("requestStartTime");
//        LOG.info("==== Log Interceptor 结束 耗时: {} ms ====",System.currentTimeMillis()-startTime);
//    }
//}
